//
//  OrderTableViewCell.m
//  mhome
//
//  Created by YaSha_Tom on 2018/12/5.
//  Copyright © 2018年 刘春雷. All rights reserved.
//

#import "OrderTableViewCell.h"

@interface OrderTableViewCell()
@property (nonatomic,strong) UIImageView *addressImg;  //地址图标
@property (nonatomic,strong) UILabel *daTitle;    //装修地址标题
@property (nonatomic,strong) UILabel *daContent;    //装修地址内容
@property (nonatomic,strong) UILabel *xiaoTitle;    //订单标题
@property (nonatomic,strong) UILabel *xiaoContent;    //订单内容

@end

@implementation OrderTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self initUI];
    }
    return self;
}
- (void)initUI {
    self.addressImg = [[UIImageView alloc]init];
    [self addSubview:self.addressImg];
    [self.addressImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(18);
        make.left.mas_equalTo(self.mas_left).offset(22);
        make.size.mas_equalTo(CGSizeMake(29*kWidthScale, 29*kHeightScale));
    }];
    
    self.daTitle = [[UILabel alloc]init];
    self.daTitle.font = [UIFont systemFontOfSize:15.0];
    self.daTitle.textColor = [UIColor colorWithRed:111.0/255.0 green:169.0/255.0 blue:231.0/255.0 alpha:1.0];
    [self addSubview:self.daTitle];
    [self.daTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(24);
        make.left.mas_equalTo(self.addressImg.mas_right).offset(8);
        make.size.mas_equalTo(CGSizeMake(100*kWidthScale, 16*kHeightScale));
    }];

    self.daContent = [[UILabel alloc]init];
    self.daContent.font = [UIFont systemFontOfSize:13.0];
    self.daContent.textAlignment = NSTextAlignmentRight;
    self.daContent.numberOfLines = 0;
    [self.contentView addSubview:self.daContent];
    [self.daContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(8);
        make.left.mas_equalTo(self.daTitle.mas_right).offset(18);
        make.size.mas_equalTo(CGSizeMake(165*kWidthScale, 42*kHeightScale));
    }];

    self.xiaoTitle = [[UILabel alloc]init];
    self.xiaoTitle.textColor = [UIColor grayColor];
    self.xiaoTitle.font = [UIFont systemFontOfSize:14.0];
    [self addSubview:self.xiaoTitle];
    [self.xiaoTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(8);
        make.left.mas_equalTo(self.contentView.mas_left).offset(24);
        make.size.mas_equalTo(CGSizeMake(80*kWidthScale, 15*kHeightScale));
    }];

    self.xiaoContent = [[UILabel alloc]init];
    self.xiaoContent.font = [UIFont systemFontOfSize:14.0];
    self.xiaoContent.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.xiaoContent];
    [self.xiaoContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(8);
        make.left.mas_equalTo(self.xiaoTitle.mas_right).offset(24);
        make.size.mas_equalTo(CGSizeMake(220*kWidthScale, 15*kHeightScale));
    }];
}

- (void)setOrderData:(orderModel *)model {
   NSArray *arr =@[@"装修地址",@"业主",@"装修系列",@"订单状态",@"订单阶段"];
    if (model.indexpath.row %5 == 0) {
        self.daTitle.text = arr[model.indexpath.row];
        self.addressImg.image = [UIImage imageNamed:@"地址"];
        self.daContent.text = [NSString stringWithFormat:@"%@%@%@",model.province,model.city,model.area];
        UILabel *la = [[UILabel alloc]initWithFrame:CGRects(24, 61, 316, 1)];
        la.backgroundColor = [UIColor colorWithRed:166.0/255.0 green:174.0/255.0 blue:184.0/255.0 alpha:1.0];
        [ self.contentView addSubview:la];
    }
    else
    {
        self.xiaoTitle.text = arr[model.indexpath.row];
        switch (model.indexpath.row) {
            case 1:
            self.xiaoContent.text = model.ownerName;
            break;
            case 2:
            self.xiaoContent.text = [NSString stringWithFormat:@"%@系列",model.styleLikeName];
            break;
            case 3:
            self.xiaoContent.text = model.mstatusName;
            break;
            case 4:
            if ([model.mstatusName isEqualToString:@"意向待分发"] ||[model.mstatusName isEqualToString:@"意向未分发关闭"]) {
                 self.xiaoContent.text = @"预约阶段";
            }
            if ([model.mstatusName isEqualToString:@"意向处理中"] ||[model.mstatusName isEqualToString:@"意向关闭"]||[model.mstatusName isEqualToString:@"意向暂停"] ) {
                self.xiaoContent.text = @"前期沟通";
            }
            if ([model.mstatusName isEqualToString:@"订单处理中"] ||[model.mstatusName isEqualToString:@"订单关闭"]||[model.mstatusName isEqualToString:@"订单暂停"] ) {
                self.xiaoContent.text = @"定金阶段";
            }
            
            if ([model.mstatusName isEqualToString:@"合同处理中"] ||[model.mstatusName isEqualToString:@"合同终止"] ||[model.mstatusName isEqualToString:@"合同暂停"] ||[model.mstatusName isEqualToString:@"合同待接收"]) {
                self.xiaoContent.text = @"合同签订";
            }
            if ([model.mstatusName isEqualToString:@"项目已接收"] ||[model.mstatusName isEqualToString:@"项目待开工"] ||[model.mstatusName isEqualToString:@"项目施工中"] ||[model.mstatusName isEqualToString:@"项目终止"] ) {
                self.xiaoContent.text = @"施工阶段";
            }
            if ([model.mstatusName isEqualToString:@"项目暂停"] ||[model.mstatusName isEqualToString:@"项目竣工"]) {
                self.xiaoContent.text = @"竣工阶段";
            }
            break;
            
            default:
            break;
        }
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
